package com.zbbt.sportslottery.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.zbbt.sportslottery.ui.fragment.ActionCenterFragment;
import com.zbbt.sportslottery.ui.fragment.ExchangeRecordFragment;
import com.zbbt.sportslottery.ui.fragment.FindingFragment;
import com.zbbt.sportslottery.ui.fragment.HomeFragment;
import com.zbbt.sportslottery.ui.fragment.IndexFragment;
import com.zbbt.sportslottery.ui.fragment.LotteryShopFragment;
import com.zbbt.sportslottery.ui.fragment.MatchDataFragment;
import com.zbbt.sportslottery.ui.fragment.SaoYiSaoFragment;
import com.zbbt.sportslottery.ui.fragment.UserFragment;

import android.support.v4.app.Fragment;

/**
 * @author kanle MainActivity全局控制跳转
 * 
 *         GotoType 判断是跳转activity还是fragment ActionKey 跳转 activity Key
 *         FragmentKey 跳转 FragmentKey Key 实例： 跳转activity： Intent i = new
 *         Intent(RegisterActivity.this, MainActivity.class);
 *         i.putExtra(KeyUtil.GotoType, KeyUtil.GOTO_ACTION);
 *         i.putExtra(KeyUtil.FragmentKey,LoginActivity.class);
 *         //直接写要跳转的activity startActivity(i); 跳转fragment： Intent i = new
 *         Intent(RegisterActivity.this, MainActivity.class);
 *         i.putExtra(KeyUtil.GotoType, KeyUtil.GOTO_FRAGMENT);
 *         i.putExtra(KeyUtil.FragmentKey,"1"); //要跳转的fragment位置
 *         startActivity(i);
 * 
 */
public class KeyUtil {

	public static final String GotoType = "GotoWhere";
	public static final String ActionKey = "ActionKey";
	public static final String FragmentKey = "FragmentKey";
	public static final int GOTO_ACTION = 1;
	public static final int GOTO_FRAGMENT = 2;
	private static ArrayList<Fragment> listfragment = new ArrayList<Fragment>();
	// public static List<Fragment> fragments = new ArrayList<Fragment>();//
	// 初始化存储fragment
	public static int FRAGMENT_HOME = 0;
	public static int FRAGMENT_DRAW = 1;
	public static int FRAGMENT_ACTION = 2;
	public static int FRAGMENT_MATCHDATA = 3;
	public static int FRAGMENT_FEED = 4;
	public static int FRAGMENT_SETTING = 5;
	public static int FRAGMENT_FAXIAN = 6;
	public static int FRAGMENT_ELEVEN = 7;
	public static int FRAGMENT_SAOYISAO = 8;
	public static int FRAGMENT_EXCHANGERECORD = 9;
	public static int FRAGMENT_USERCENTER = 10;

	public static int FRAG_HOME = 0;
	public static int FRAG_NEWS = 1;
	public static int FRAG_ACTION = 2;
	public static int FRAG_FIND = 3;
	public static int FRAG_USER = 4;

	public static void initFragment() {
		Fragment fragHome = IndexFragment.getInstance();
		Fragment fragNews = HomeFragment.getInstance();
		Fragment fragAction = ActionCenterFragment.getInstance();
		Fragment fragFind = FindingFragment.getInstance();
		Fragment fragUser = UserFragment.getInstance();
		if (listfragment.isEmpty()) {
			listfragment.add(fragHome);
			listfragment.add(fragNews);
			listfragment.add(fragAction);
			listfragment.add(fragFind);
			listfragment.add(fragUser);
		}
	}

	public void addFragment(Fragment fragment) {
		listfragment.add(fragment);
	}

	public static Fragment getFragment(int key) {
		return listfragment.get(key);
	}

	public static int getFragmentSize() {
		return listfragment.size();
	}

	public static ArrayList<Fragment> getFragments() {
		return listfragment;
	}

}
